home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
windows
/
comman10.zip
/
COMMAN.WAS
Wrap
Text File
|
1992-10-14
|
7KB
|
148 lines
; ComMan.WAS v 1.00 COM port monitor
;****************************************************************************
;* *
;* COMMAN.WAS *
;* Copyright (C) 1992 Datastorm Technologies, Inc. *
;* All rights reserved. *
;* *
;* Purpose: Monitors COM port activity, displaying number of characters in *
;* the receive and transmit buffers, state of CD (high or low), *
;* and state of flow control (clear, XOFF, or CTS). *
;* *
;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming. *
;* DATASTORM makes no warranty of any kind, express or implied, including *
;* without limitation, any warranties of merchantability and/or fitness *
;* for a particular purpose. Use of this program is at your own risk. *
;* *
;* Author: Chuck Spohr *
;* *
;****************************************************************************
;****************************************************************************
;* GLOBAL VARIABLES *
;****************************************************************************
integer RXi, OldRxi=-1, TXi, OldTxi=-1, CDi, OldCDi=-1, FLi, OldFLi=-1, Change
string RX="", TX="", CD="Low", FL="Clear"
;****************************************************************************
;* *
;* MAIN *
;* The Main procedure first records the window ID's, then enters a loop to *
;* monitor the status of the current COM port. *
;* *
;* Calls: Dlg, CheckStat, *
;* Modifies globals: none *
;* *
;****************************************************************************
proc Main
integer ComManWin, LastWin, CurWin
CurWin=$ACTIVEWIN ; Record PW window ID
Dlg() ; Display dialogbox
ComManWin=$ACTIVEWIN ; Record script window ID
activatewin CurWin ; Make script window active
while !$DIALOG ; Run until dialogbox is closed
LastWin=CurWin ; Keep script in background
if (CurWin=$ActiveWin) == ComManWin
activatewin LastWin
endif
CheckStat()
if Change
updatedlg 64
Change=0
endif
endwhile
endproc
;****************************************************************************
;* *
;* CHECKSTAT *
;* The CheckStat checks $RXCOUNT, $TXCOUNT, $CARRIER and $FLOWSTATE. If a *
;* change is sensed, the old value is stored, and the new value is *
;* retrieved. *
;* *
;* Calls: none *
;* Modifies globals: RXi, OldRxi, TXi, OldTxi, CDi, OldCDi, FLi, OldFLi *
;* Change, RX, TX, CD, FL *
;* *
;****************************************************************************
proc CheckStat
RXi=$RXCOUNT ; Get number of characters in receive data buffer
if RXi!=OldRXi ; Is it different than the last check?
Change=1 ; If so, flag a change
OldRXi=RXi ; store the value
if RXi ; and set the string variable
itoa RXi RX
else
RX="" ; If there are no characters, clear the string
endif
endif
TXi=$TXCOUNT ; Get number of characters in transmit buffer
if TXi!=OldTXi
Change=1
OldTXi=TXi
if TXi
itoa TXi TX
else
TX=""
endif
endif
CDi=$CARRIER ; Get the state of Carrier Detect
if CDi!=OldCDi
Change=1
OldCDi=CDi
if CDi
CD="High"
else
CD="Low"
endif
endif
FLi=$FLOWSTATE ; Get the state of flow control
if FLi!=OldFLi
Change=1
OldFLi=FLi
if FLi ; If flow is paused, determine if it was due to XOFF
if strcmp $LASTMSG "XOFF received"
FL="XOFF"
else
FL="CTS" ; If not XOFF, then it must be CTS
endif
statmsg "" ; Clear statline and $LASTMSG
else
FL="Clear" ; If flow is not paused, set string to "Clear"
endif
endif
endproc
;****************************************************************************
;* *
;* DLG *
;* The Dlg procedure displays the main dialogbox *
;* *
;* Calls: none *
;* Modifies globals: none *
;* *
;****************************************************************************
proc Dlg
dialogbox 250 0 45 33 6 "ComMan"
text 3 0 16 8 right "RX:"
text 3 8 16 8 right "TX:"
text 3 16 16 8 right "CD:"
text 3 24 17 8 right "Flow:"
vtext 21 0 24 9 left RX
vtext 21 8 24 9 left TX
vtext 21 16 24 9 left CD
vtext 21 24 24 9 left FL
enddialog
endproc